import { PreloadingStrategy, Route } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { of } from 'rxjs/observable/of';

export class AppCustomPreloader implements PreloadingStrategy {
  preload(route: Route, load: Function): Observable<any> {
    return route.data && 
    route.data.preload && 
    (!route.data.whenAuth || 
        (route.data.whenAuth == true && 
        localStorage.getItem('sust:a'))) ? load() : of(null);
  }
}